﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ex03.VehicalsObjectModel
{
    public class VehicalWheel
    {
        // Data Members
        private const float k_MinPSI = 0;
        private float m_MaxPSI;
        private float m_CurrentPSI;

        /// <summary>
        /// Creates a new wheel with maximum PSI
        /// </summary>
        /// <param name="i_MaxPSI">The limit of PSI for the wheel</param>
        public VehicalWheel(float i_MaxPSI)
        {
            m_MaxPSI = i_MaxPSI;
            m_CurrentPSI = k_MinPSI;
        }

        /// <summary>
        /// Gets and the current PSI for the wheel
        /// </summary>
        public float CurrentPSI
        {
            get 
            { 
                return m_CurrentPSI; 
            }
        }

        /// <summary>
        /// Gets the maximum PSI for the wheel
        /// </summary>
        public float MaxPSI
        {
            get 
            { 
                return m_MaxPSI; 
            }
        }

        /// <summary>
        /// Inflates the wheel to a target PSI
        /// </summary>
        /// <param name="i_TargetPSI">The target PSI of the wheel</param>
        /// <exception cref="ValueOutOfRangeException">When the PSI is to small or exceeds the maximum PSI of the wheel</exception>
        public void Inflate(float i_TargetPSI)
        {
            // Check validation
            if (i_TargetPSI < k_MinPSI || i_TargetPSI > MaxPSI)
            {
                throw new ValueOutOfRangeException(k_MinPSI, MaxPSI);
            }
            else
            {
                // Update the PSI
                m_CurrentPSI = i_TargetPSI;
            }
        }
    }
}
